# 猜数字小游戏
import random
# 生成随机数a
a = random.randint(1,100)
print('------猜数字游戏！-----')

while True:   
    b = input('猜数字游戏开始，猜猜是啥：')
    guess = int(b)
    if guess > a:
        print('大啦大啦，往小里猜~')
    elif guess < a:
        print('小了小了，再来')
    else:
        print('诶嘿猜对了，你可真是个小聪明。')
        print('游戏结束，好玩吧。')
    break


# 字典查询练习
# 获取json数据
results=[{'faceId': '7383e308-015f-4e21-8cb4-021675d03a57',
  'faceRectangle': {'top': 310, 'left': 404, 'width': 259, 'height': 259},
  'faceAttributes': {'smile': 0.806,
   'headPose': {'pitch': 7.4, 'roll': 1.0, 'yaw': 3.0},
   'gender': 'female',
   'age': 18.0,
   'facialHair': {'moustache': 0.0, 'beard': 0.0, 'sideburns': 0.0},
   'glasses': 'ReadingGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.069,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.806,
    'neutral': 0.125,
    'sadness': 0.0,
    'surprise': 0.0},
   'blur': {'blurLevel': 'low', 'value': 0.0},
   'exposure': {'exposureLevel': 'goodExposure', 'value': 0.65},
   'noise': {'noiseLevel': 'high', 'value': 0.96},
   'makeup': {'eyeMakeup': False, 'lipMakeup': True},
   'accessories': [{'type': 'glasses', 'confidence': 1.0}],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.13,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 0.88},
     {'color': 'brown', 'confidence': 0.8},
     {'color': 'blond', 'confidence': 0.43},
     {'color': 'gray', 'confidence': 0.36},
     {'color': 'other', 'confidence': 0.36},
     {'color': 'red', 'confidence': 0.12},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': 'afac4868-b65a-4f63-b756-88cf55f12096',
  'faceRectangle': {'top': 325, 'left': 96, 'width': 250, 'height': 250},
  'faceAttributes': {'smile': 0.916,
   'headPose': {'pitch': -6.1, 'roll': -0.4, 'yaw': 13.0},
   'gender': 'female',
   'age': 20.0,
   'facialHair': {'moustache': 0.0, 'beard': 0.0, 'sideburns': 0.0},
   'glasses': 'NoGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.0,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.916,
    'neutral': 0.083,
    'sadness': 0.0,
    'surprise': 0.001},
   'blur': {'blurLevel': 'low', 'value': 0.18},
   'exposure': {'exposureLevel': 'goodExposure', 'value': 0.47},
   'noise': {'noiseLevel': 'medium', 'value': 0.38},
   'makeup': {'eyeMakeup': True, 'lipMakeup': True},
   'accessories': [],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.1,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 0.92},
     {'color': 'brown', 'confidence': 0.92},
     {'color': 'other', 'confidence': 0.34},
     {'color': 'red', 'confidence': 0.22},
     {'color': 'gray', 'confidence': 0.18},
     {'color': 'blond', 'confidence': 0.18},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': '5a99329b-f094-4c31-9c19-539ee0274cca',
  'faceRectangle': {'top': 456, 'left': 712, 'width': 178, 'height': 178},
  'faceAttributes': {'smile': 0.02,
   'headPose': {'pitch': -2.1, 'roll': 29.5, 'yaw': 13.5},
   'gender': 'female',
   'age': 19.0,
   'facialHair': {'moustache': 0.0, 'beard': 0.0, 'sideburns': 0.0},
   'glasses': 'ReadingGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.542,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.02,
    'neutral': 0.438,
    'sadness': 0.0,
    'surprise': 0.0},
   'blur': {'blurLevel': 'low', 'value': 0.0},
   'exposure': {'exposureLevel': 'goodExposure', 'value': 0.52},
   'noise': {'noiseLevel': 'high', 'value': 0.75},
   'makeup': {'eyeMakeup': False, 'lipMakeup': False},
   'accessories': [{'type': 'glasses', 'confidence': 0.98},
    {'type': 'headwear', 'confidence': 0.98}],
   'occlusion': {'foreheadOccluded': True,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.0, 'invisible': True, 'hairColor': []}}},
 {'faceId': 'aa13b354-631b-481e-b426-d4e811aee143',
  'faceRectangle': {'top': 252, 'left': 861, 'width': 138, 'height': 148},
  'faceAttributes': {'smile': 0.001,
   'headPose': {'pitch': -0.3, 'roll': 5.7, 'yaw': 9.2},
   'gender': 'female',
   'age': 22.0,
   'facialHair': {'moustache': 0.0, 'beard': 0.0, 'sideburns': 0.0},
   'glasses': 'ReadingGlasses',
   'emotion': {'anger': 0.0,
    'contempt': 0.001,
    'disgust': 0.0,
    'fear': 0.0,
    'happiness': 0.001,
    'neutral': 0.98,
    'sadness': 0.018,
    'surprise': 0.0},
   'blur': {'blurLevel': 'low', 'value': 0.12},
   'exposure': {'exposureLevel': 'goodExposure', 'value': 0.6},
   'noise': {'noiseLevel': 'medium', 'value': 0.67},
   'makeup': {'eyeMakeup': True, 'lipMakeup': False},
   'accessories': [{'type': 'glasses', 'confidence': 0.99}],
   'occlusion': {'foreheadOccluded': False,
    'eyeOccluded': False,
    'mouthOccluded': False},
   'hair': {'bald': 0.11,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 0.97},
     {'color': 'brown', 'confidence': 0.86},
     {'color': 'gray', 'confidence': 0.44},
     {'color': 'other', 'confidence': 0.35},
     {'color': 'blond', 'confidence': 0.15},
     {'color': 'red', 'confidence': 0.06},
     {'color': 'white', 'confidence': 0.0}]}}}]

# 在用数据结构查询的方式查找到：眼镜、肤色、微笑指数、头发颜色、年龄、性别这几项数据

# 创建空列表
glass=[]
smiling=[]
hair_color=[]
age=[]
gender=[]


# 调用append增加对象
age.append(results[0]['faceAttributes']['age'])
age.append(results[1]['faceAttributes']['age'])
age.append(results[2]['faceAttributes']['age'])
age.append(results[3]['faceAttributes']['age'])
print('age的集合:%s'%age)
# 返回数值：age的集合:[18.0, 20.0, 19.0, 22.0]

smiling.append(results[0]['faceAttributes']['smile'])
smiling.append(results[1]['faceAttributes']['smile'])
smiling.append(results[2]['faceAttributes']['smile'])
smiling.append(results[3]['faceAttributes']['smile'])
print('smiling的集合:%s '%smiling)
# 返回数据：smiling的集合:[0.806, 0.916, 0.02, 0.001] 

glass.append(results[0]['faceAttributes']['glasses'])
glass.append(results[1]['faceAttributes']['glasses'])
glass.append(results[2]['faceAttributes']['glasses'])
glass.append(results[3]['faceAttributes']['glasses'])
print('glass的集合:%s'%glass)
# 返回数据：glass的集合:['ReadingGlasses', 'NoGlasses', 'ReadingGlasses', 'ReadingGlasses']


gender.append(results[0]['faceAttributes']['gender'])
gender.append(results[1]['faceAttributes']['gender'])
gender.append(results[2]['faceAttributes']['gender'])
gender.append(results[3]['faceAttributes']['gender'])
print('gender的集合:%s'%gender)
# 返回数据：gender的集合:['female', 'female', 'female', 'female']


hair_color.append(results[0]['faceAttributes']['hair'])
hair_color.append(results[1]['faceAttributes']['hair'])
hair_color.append(results[2]['faceAttributes']['hair'])
hair_color.append(results[3]['faceAttributes']['hair'])
print('hair_color的集合:%s'%hair_color)






